<?php
// +-------------------------------------------------------------------------------
// | DingZone [ A Rapid Development Framework For Dingtalk ]
// +-------------------------------------------------------------------------------
// | 钉钉企业用户创建及修改请求类 v1.0
// |
// | Copyright (c) 2014-2018 http://www.heimalanshi.com All rights reserved.
// | Author : Jie
// | Date : 2018-08-09
// +-------------------------------------------------------------------------------

namespace ding\request;

/**
 * 发起待办请求
 *
 * @package ding\request
 */
class WorkrecordAddRequest extends DingApiRequest {
    /**
     * 工唯一标识ID（不可修改），企业内必须唯一。长度为1~64个字符，如果不传，服务器将自动生成一个userid
     * @var string
     */
    private $userid;
    /**
     * 待办时间。Unix时间戳，毫秒级
     *
     * @var int
     */
    private $create_time;
    /**
     * 待办事项的标题
     *
     * @var string
     */
    private $title;
    /**
     * 待办事项的跳转链接
     *
     * @var
     */
    private $url;
    /**
     * 待办事项表单
     *
     * @var
     */
    private $formItemList;

    public function __construct($userid, $title, $url) {
        $this->userid = $userid;
        $this->title = $title;
        $this->url = $url;
        $this->create_time = time() * 1000;
    }

    /**
     * 添加待办事项表单元素
     *
     * @param $title
     * @param $content
     * @return $this
     */
    public function addFormItem($title, $content) {
        if (!is_array($this->formItemList)) {
            $this->formItemList = [];
        }
        $this->formItemList[] = [
            'title' => $title,
            'content' => $content
        ];
        return $this;
    }

    /**
     * @return string
     */
    public function getUserid() {
        return $this->userid;
    }

    /**
     * @param string $userid
     * @return WorkrecordAddRequest
     */
    public function setUserid($userid) {
        $this->userid = $userid;
        return $this;
    }

    /**
     * @return int
     */
    public function getCreateTime() {
        return $this->create_time;
    }

    /**
     * @param int $create_time
     * @return WorkrecordAddRequest
     */
    public function setCreateTime($create_time) {
        $this->create_time = $create_time;
        return $this;
    }

    /**
     * @return string
     */
    public function getTitle() {
        return $this->title;
    }

    /**
     * @param string $title
     * @return WorkrecordAddRequest
     */
    public function setTitle($title) {
        $this->title = $title;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getUrl() {
        return $this->url;
    }

    /**
     * @param mixed $url
     * @return WorkrecordAddRequest
     */
    public function setUrl($url) {
        $this->url = $url;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getFormItemList() {
        return $this->formItemList;
    }

    /**
     * @param mixed $formItemList
     * @return WorkrecordAddRequest
     */
    public function setFormItemList($formItemList) {
        $this->formItemList = $formItemList;
        return $this;
    }


}